package io.renren.roomManager.controller;

import cn.lingyueblog.common.utils.PageUtils;
import cn.lingyueblog.common.utils.R;
import io.renren.roomManager.entity.RoomsEntity;
import io.renren.roomManager.service.RoomsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Map;

/**
 * 
 *
 * @author zhenliu
 * @email 2368410997@qq.com
 * @date 2024-06-17 12:56:03
 */
@RestController
@RequestMapping("roomManager/rooms")
public class RoomsController {
    @Autowired
    private RoomsService roomsService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = roomsService.queryPage(params);

        return R.ok().put("page", page);
    }

    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    public R info(@PathVariable("id") Integer id){
		RoomsEntity rooms = roomsService.getById(id);

        return R.ok().put("rooms", rooms);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody RoomsEntity rooms){
//		roomsService.save(rooms);
        roomsService.roomSave(rooms);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody RoomsEntity rooms){
		roomsService.updateById(rooms);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] ids){
		roomsService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
